package com.hm.result;

import com.hm.entity.Users;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 文希
 * @create 2019-06-19 10:03
 **/
public class MyResultSetHandler implements ResultSetHandler {

    public Object handle(ResultSet resultSet) throws SQLException {
        List<Users> list = new ArrayList<Users>();
        while (resultSet.next()){
            Integer id = resultSet.getInt(1);
            String name = resultSet.getString(2);
            Integer age = resultSet.getInt(3);
            String address = resultSet.getString(4);
            Users users = new Users(id, name, address, age);
            list.add(users);
        }
        return list;
    }
}
